package cn.caskm.souvenirshopsystem.controller.admin;

import cn.caskm.souvenirshopsystem.domain.Result;
import cn.caskm.souvenirshopsystem.domain.dto.PageDTO;
import cn.caskm.souvenirshopsystem.domain.po.GoodsOrder;
import cn.caskm.souvenirshopsystem.domain.query.PageQuery;
import cn.caskm.souvenirshopsystem.service.GoodsOrderService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/goodsOrder")
@RequiredArgsConstructor
public class AdminGoodsOrderController {

    private final GoodsOrderService goodsOrderService;

    @GetMapping("/page")
    public Result<PageDTO<GoodsOrder>> page(PageQuery query) {
        return goodsOrderService.page(query);
    }
    
    @GetMapping("/list")
    public Result<List<GoodsOrder>> list() {
        return goodsOrderService.getAll();
    }

    @GetMapping("/detail/{id}")
    public Result<GoodsOrder> detail(@PathVariable("id") Integer id) {
        return goodsOrderService.detail(id);
    }

    @PostMapping("/saveOrUpdate")
    public Result<Object> saveOrUpdate(@RequestBody GoodsOrder goodsOrder) {
        goodsOrderService.saveOrUpdateEntity(goodsOrder);
        return Result.success();
    }

    @DeleteMapping("/deleteById/{id}")
    public Result<Object> deleteById(@PathVariable("id") Integer id) {
        goodsOrderService.removeById(id);
        return Result.success();
    }
} 